{% extends "base_navigation.html" %}
{% load set_val %}
{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    {% block head_part %}
        <title>APP编译概览</title>
        <link rel="stylesheet" href="{% static 'Form_Style/css/style-nav.css' %}">
        <link rel="stylesheet" type="text/css" href="{% static 'bootstrap-3.3.7-dist/css/bootstrap.min.css' %}">
        <link rel="stylesheet" type="text/css" href="{% static 'fy-alert/css/fy-alert.css' %}">
    {% endblock %}
</head>

<body>
  {% block user_who %}| User：{{ username }}{% endblock user_who %}
  {% block body_part %}
      <article style="top: 20%">
      <table class="table table-hover">
          <thead>
              <tr>
                   <th>app名</th>
                   <th>显示名</th>
                   <th>上次编译时间</th>
                   <th>下次编译时间</th>
                   <th>app状态</th>
                   <th>编译</th>
                   <th>定时编译</th>
                    <th>查看编译状态</th>
              </tr>
          </thead>

          {% for tmp_app in app_databases_all %}
              <tr>
                <td>{{ tmp_app.name }}</td>
                <td>{{ tmp_app.app_english_name }}</td>
                <td>{{ tmp_app.app_compile_time }}</td>

                <td>
                    {% for tmp_task in task_list_clock %}
                        {% if tmp_task.args.0 == tmp_app.pk %}
{#                            {{ clock_flag|add:"1" }}#}
                            {{ tmp_task.next_run_time }}
{#                            {{ clock_flag }}#}
{#                            {% clock_flag= %}#}
                        {% endif %}
                    {% endfor %}
{#                {% set clock_flag = 1111 %}#}

                </td>
                <td>
                    {% if  tmp_app.app_condition == "running"  %}
                        <button type="button" class="btn btn-danger">正在使用</button>
                    {% elif tmp_app.app_condition == "compiling" %}
                        <button type="button" class="btn btn-warning">正在编译</button>
                    {% elif tmp_app.app_condition == "free" %}
                        <button type="button" class="btn btn-success">可以编译</button>
{#                        <p class="bg-success">可以编译</p>#}
                    {% endif %}
                </td>
                 <td>
                     {% if tmp_app.app_condition == "free" %}
                        <button type="button" class="btn btn-primary btn-sm" href="{% url "tool:compile" tmp_app.pk %}" onclick="resp_confirm(this)">编译{{ tmp_app.app_english_name }}</button>
                     {% else %}
                         <button type="button" class="btn btn-primary btn-sm" href="{% url "tool:compile" tmp_app.pk %}" onclick="resp_confirm(this)" disabled>编译{{ tmp_app.app_english_name }}</button>
                     {% endif %}
                 </td>
                  <td>
                      {% if tmp_app.pk in clock_app_pk_list %}

                          <button type="button" class="btn btn-primary btn-sm" href="{% url "tool:remove_app_clock" tmp_app.pk %}" onclick="dele_confirm(this)">删除定时任务</button>
                      {% else %}

                           <button type="button" class="btn btn-primary btn-sm" href="{% url "tool:compile_clock" tmp_app.pk %}" onclick="app_clock_compile(this)">定时</button>
                      {% endif %}
                  </td>
                <td>
                     <button type="button" class="btn btn-primary btn-sm" href="{% url "tool:inquery_compile" tmp_app.pk %}" onclick="inquery(this)" >查询编译状态</button>
                </td>
{#                   <td> <a href="{% url "file_manage:remove_task" tmp_file.pk %}" onclick="confirm('确认删除吗？')">删除该任务</a></td>#}
{#                <td> <button type="button" class="btn btn-primary btn-sm">删除文件</button></td>#}
              </tr>

          {% endfor %}
      </table>
      </article>
      <script  src="{% static 'Form_Style/download_js/script-nav.js' %}"></script>
      <script type="text/javascript" src="{% static 'index/js/jquery-3.3.1.js' %}"></script>
      <script type="text/javascript" src="{% static 'fy-alert/js/fy-alert.js' %}"></script>
      <script>
            　　function resp_confirm(tmp) {
                  if (confirm('确认编译吗？')) {
                      window.top.location.href = tmp.getAttribute("href")
                  }
              }
               　　function dele_confirm(tmp){
            　　　　if (confirm('确认删除吗？')){
                      window.top.location.href=tmp.getAttribute("href")
                }
            　　}
                function inquery(tmp) {
                    $.get(tmp.getAttribute("href"),
                    function(result) {
                        {#$("#preview").html(result);#}
                        	fyAlert.alert({
                            title:"编译情况",
                            type:1,
                            minmax:true,
                            animateType : 1,
                            direction:['center','bottom'],
                            area : ['100%','50%'],
                            content: result,
                        })
                    });
                }
                function app_clock_compile(tmp) {
                    {#$("#preview").html(result);#}
                    result=tmp.getAttribute("href")
                    {#result="https://www.baidu.com"#}
                    fyAlert.alert({
                        title:"定时操作",
                        type:2,
                        minmax:true,
                        animateType : 1,
                        direction:['center','bottom'],
                        area : ['100%','50%'],
                        content: result,
                    })
                }


      </script>
  {% endblock %}

</body>
</html>